/* GUI CONVERTED from mfcsdate.i (converter v1.75) Tue Apr 10 12:02:10 2001 */
/* mfcsdate.i - CALCULATES START DATES FOR LOAD AND MRP REPORTS         */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.4 $                                                     */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 1.0      LAST MODIFIED: 04/23/86         BY: EMB           */
/* REVISION: 4.0      LAST MODIFIED: 03/25/88         BY: pml A158      */
/* REVISION: 7.2      LAST MODIFIED: 08/02/94         BY: jxz *FP82*    */
/* REVISION: 9.1      LAST MODIFIED: 08/13/00         BY: *N0KR* myb    */
/* Old ECO marker removed, but no ECO header exists *F0PN*              */
/* $Revision: 1.4 $    BY: Katie Hilbert  DATE: 04/01/01 ECO: *P008*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* USES VARIABLES: sdate[*], interval[*], start, monthend,       */
/* num_intervals, dwm, i, idays                                  */

/* COMPUTE START DATES */
assign
   sdate[2] = start
   interval[1] = sdate[2] - sdate[1].
if month(start + 1) <> month(start)
then monthend = 1.
else monthend = 0.

do i = 3 to num_intervals + 1:
    IF sdate[i - 1] < sdate[2] + 28 - (weekday(sdate[2]) - 1) THEN do:
        sdate[i] = sdate[i - 1] + 1.
    END.
    ELSE DO:
        sdate[i] = sdate[i - 1] + 7.
    END.
/*    if dwm = "d" then sdate[i] = sdate[i - 1] + idays.                                 */
/*    if dwm = "w" then sdate[i] = sdate[i - 1] + 7 * idays.                             */
/*    if dwm = "m" then do:                                                              */
/*       sdate[i] = date((((month (sdate[i - 1]) - 1) modulo 12 + idays) modulo 12 + 1), */
/*          min (28,day (sdate[2])), integer (year (sdate[i - 1]) +                      */
/*          truncate ((month (sdate[i - 1]) + idays) / 12.00001,0))).                    */
/*       do while (day (sdate[i]) < day (sdate[2]) and monthend = 0) and                 */
/*                (month (sdate[i] + 1) = month (sdate[i])):                             */
/*          sdate[i] = sdate[i] + 1.                                                     */
/*       end.                                                                            */
/*    end.                                                                               */
/*    if dwm = "p" then do:                                                              */
/*       find first glc_cal where glc_start > sdate[i - 1] no-lock no-error.             */
/*                                                                                       */
/*       if available glc_cal then do:                                                   */
/*          assign                                                                       */
/*             sdate[i] = glc_start                                                      */
/*             dwm = string(idays).                                                      */
/*          do idays = 1 to integer(dwm) - 1:                                            */
/*             find next glc_cal no-lock no-error.                                       */
/*             if available glc_cal then sdate[i] = glc_start.                           */
/*             else do:                                                                  */
/*                find last glc_cal where glc_year = year(sdate[i - 1])                  */
/*                   no-lock no-error.                                                   */
/*                if available glc_cal then sdate[i] = glc_end + 1.                      */
/*             end.                                                                      */
/*          end.                                                                         */
/*       end.                                                                            */
/*       else do:                                                                        */
/*          find last glc_cal where glc_year = year(sdate[i - 1])                        */
/*             no-lock no-error.                                                         */
/*          if available glc_cal                                                         */
/*          then sdate[i] = glc_end + 1.                                                 */
/*          else sdate[i] = sdate[i - 1] + 7 * idays.                                    */
/*       end.                                                                            */
/*       dwm = "p".                                                                      */
/*    end.                                                                               */

   interval[i - 1] = sdate[i] - sdate[i - 1].
end.
